public class QuickSort {

    public static void quickSort(int[] elem){
        Sort(elem,0,elem.length);
    }
    public static void Sort(int[] elem, int left,int right){
        if (left >= right){
            return;
        }
        int par = seekpar(elem,left,right);

        Sort(elem,left,par);

        Sort(elem,par+1,right);

    }
    public static int seekpar(int[] elem,int left,int right){
        int prev = left;
        int cur = left+1;
        while (cur < right){
            if (elem[cur] < elem[left] && elem[++prev] != elem[cur]){
                swap(elem,cur,prev);
            }
            cur++;
        }
        swap(elem,prev,left);
        return prev;
    }

    public static void swap(int[] array,int i,int j){
        int cur = array[i];
        array[i] = array[j];
        array[j] = cur;
    }


}
